// node gulpfile.js  部署UAT uat:Du707294
'use strict'

const childProcess = require('child_process')
// const config = require(`./config.gulp.js`)
const dev = 'UAT'

console.log(`部署${dev}.....`)
console.log('准备资源并压缩...')
console.log(`tar -zcvf ./dist.tar.gz ./dist`)
childProcess.execSync(`tar -zcvf ./dist.tar.gz ./dist`)
//需要先在服务器上创建temp文件夹
console.log('scp')
console.log(
  `scp  ./dist.tar.gz root@101.43.135.107:/data/nginx/www/temp`
)
childProcess.execSync(
  `scp  ./dist.tar.gz root@101.43.135.107:/data/nginx/www/temp`
)

console.log('解压.....')
// console.log(`ssh root@101.43.135.107 "rm -rf /data/nginx/www/html/vue2;mkdir /data/nginx/www/html/vue2;cp -r /data/nginx/www/temp/dist/assets/ /data/nginx/www/html/vue2;cp /data/nginx/www/temp/index.html /data/nginx/www/html/vue2;cd /data/nginx/www/temp;tar -zxvf ./dist.tar.gz;cp -rf ./dist/* /data/nginx/www/html/vue2;dokcer stop nginx;docker start nginx;"`)
console.log(`ssh root@101.43.135.107 "rm -rf /data/nginx/www/html/vue2;mkdir /data/nginx/www/html/vue2;cd /data/nginx/www/temp;tar -zxvf ./dist.tar.gz;cp -rf ./dist/* /data/nginx/www/html/vue2;docker stop nginx;docker start nginx;"`)
childProcess.execSync(
    `ssh root@101.43.135.107 "rm -rf /data/nginx/www/html/vue2;mkdir /data/nginx/www/html/vue2;cd /data/nginx/www/temp;tar -zxvf ./dist.tar.gz;cp -rf ./dist/* /data/nginx/www/html/vue2;docker stop nginx;docker start nginx;"`
)
console.log('部署完成.....')
// docker stop nginx;docker start nginx;